import tkinter
from turtle import *
def class_start():
    label.config(text="大数据班上课")
def class_end():
    label.config(text="大数据班下课")
def lecture():
    label.config(text="正在讲课")
    line()
def line():
    color('red', 'green')
    begin_fill()
    count = 0  # 添加循环次数计数器
    max_count = 1000  # 设置最大循环次数
    while True:
        forward(200)
        left(170)
        if abs(pos()) < 1 or count > max_count:  # 添加循环次数检查条件
            break
        count += 1  # 每次循环增加计数器
    end_fill()
    done()
root = tkinter.Tk()
root.geometry("600x600")
my_font = ('Arial', 12, 'bold')
# 实例化标签（label）组件
label = tkinter.Label(root, text="付老师课堂")
label.pack()
# 创建按钮1,并设置按钮名称“上课”
button1 = tkinter.Button(root, text="上课",
                         command=class_start,
                         width = 7, height = 1,bg='blue',
                         font=my_font, fg='yellow')
# 把按钮1添加到主界面并放到界面左侧
button1.pack(side=tkinter.LEFT)
# 创建按钮2,并设置按钮名称“下课”
button2 = tkinter.Button(root, text="下课",
                         command=class_end,
                         width = 7, height = 1,bg='red')
# 把按钮2添加到主界面并放到界面右侧
button2.pack(side=tkinter.RIGHT)
# 创建按钮3,并设置按钮名称“讲课”
button3 = tkinter.Button(root, text="讲课",
                         command=lecture,
                         width = 7, height = 1,bg='green')
# 把按钮3添加到主界面并放到界面中间
button3.pack(side=tkinter.TOP)
root.mainloop()